package com.study.test2;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class excutor1 {
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

    public synchronized static String date(int second){
        Date date = new Date(1000*second);
        return sdf.format(date);
    }

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(3);

        for (int i = 0; i < 30; i++) {
            int finalI = i;
            executorService.execute(()->{
                String date = date(finalI);
                System.out.println(date);
            });
        }
        executorService.shutdown();
    }
}
